<template>
  <div class="top_o">
    <el-card class="box-card" :style="{height:WindowHeight - cardHeight + 'px'}">
      <el-button size="small" type="primary" @click="nweJieKuanBZ">新增借款额度</el-button>
      <el-table
        :data="tableData"
        style="width:100%;"
        border
        stripe
        :max-height="WindowHeight - tabHeight"
        highlight-current-row
      >
        <el-table-column label="序号" fixed align="center" type="index" width="70" />
        <el-table-column prop="danwei" label="单位" width="180" />
        <el-table-column prop="bumen" label="部门" width="180" />
        <el-table-column prop="zhiwei" label="职务" />
        <el-table-column prop="name" label="姓名" width="180" />
        <el-table-column prop="jked" label="借款额度" align="right" width="150" />
        <el-table-column prop="ysyed" label="已使用额度" align="right" width="150" />
        <el-table-column label="剩余额度" align="right" width="140">
          <template slot-scope="scope">
            <span v-if="scope.row.syed== -100" class="qwe">{{ scope.row.syed }}</span>
            <span v-else-if="scope.row.syed!== -100" class="sdas">{{ scope.row.syed }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="170" align="center">
          <template slot-scope="scope">
            <el-button size="small" type="warning" @click="editJieKuanBZ(scope.row,scope.$index)">编辑</el-button>
            <!-- <el-button size="small" type="danger"   @click="delieKuanBZ(scope.row,scope.$index)">删除</el-button> -->
          </template>
        </el-table-column>
      </el-table>
      <div class="bottom"><page /></div>
    </el-card>

    <!-- 点击新增显示的弹框 -->
    <component :is="configName" />
  </div>
</template>

<script>
import page from '@/views/rfcwgl/components/PageS/index.vue'
import Vue from 'vue'
export default {
  components: { page },
  data() {
    return {
      WindowHeight: document.body.clientHeight,
      configName: '',
      addPath: {
        configName: 'addhuankuan',
        configFilePath: 'rfcwgl/jieKuanBZSD/append/jieKuanBZSDAppend/index.vue'
      },
      editPath: {
        configName: 'showjiekuanbz',
        configFilePath: 'rfcwgl/jieKuanBZSD/edit/jieKuanBZSDEdit/index.vue'
      },
      cardHeight: 84,
      tabHeight: 180,
      islimit: false,
      islook: false,
      isbj: false,
      tableData: [
        {
          id: 1,
          danwei: '光电',
          bumen: '技术部',
          zhiwei: '策划宣传',
          name: '张三',
          jked: 320,
          ysyed: 100,
          syed: 220
        },
        {
          id: 2,
          danwei: '光电',
          bumen: '技术部',
          zhiwei: '策划宣传',
          name: '张三',
          jked: 300,
          ysyed: 400,
          syed: -100
        },
        {
          id: 3,
          danwei: '光电',
          bumen: '技术部',
          zhiwei: '策划宣传',
          name: '张三',
          jked: 500,
          ysyed: 100,
          syed: 400
        }
      ]
    }
  },
  computed: {
    windowHeight() {
      return this.$store.state.windowH.height
    },
    tagsView() {
      return this.$store.state.settings.tagsView
    }
  },
  watch: {
    windowHeight: function(old, newd) {
      this.WindowHeight = old
    },
    tagsView: function(old, newd) {
      this.ifTagsView(old)
    }
  },
  created() {
    this.ifTagsView(this.$store.state.settings.tagsView)
  },
  methods: {
    ifTagsView(data) {
      if (data) {
        this.cardHeight = 84
        this.tabHeight = 180
      } else {
        this.cardHeight = 50
        this.tabHeight = 155
      }
    },
    openWndow(e) {
      this.configName = Vue.component(e.configName, resolve => {
        require([`@/views/${e.configFilePath}`], resolve)
      })
    },
    handleClick(tab, event) {
      console.log(tab, event)
    },
    nweJieKuanBZ() {
      this.openWndow(this.addPath)
    },
    editJieKuanBZ() {
      this.openWndow(this.editPath)
    },
    delieKuanBZ(row, index) {
      this.$confirm('确定要删除吗')
        .then(_ => {
          this.tableData.splice(index, 1)
        })
        .catch(_ => {})
    }

  }
}
</script>

<style lang='scss' scoped>
::v-deep .el-tabs__header {
  margin: 0px;
}
::v-deep .inas {
  margin-top: 2.5%;
  margin-bottom: 3%;
  margin-left: 80%;
}
.title {
  font-size: 20px;
  margin-left: 30px;
  height: 16px;
  font-weight: 600;
  .wqx {
    float: left;
  }
  .el-button {
    margin-right: 10px;
  }
}
::v-deep .el-drawer {
  overflow-y: scroll !important;
}
// tab切换
.sadayu {
  display: inline-block;

  position: absolute;
  left: 85%;
  top: 2%;
}
.qwe{
  color: red;
}
.sdas{
  color: #00AC6C;
}
::v-deep .ytyt{
  width: 92% !important;
}
</style>
